home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cocktail / reuse.lha / reuse / m2c / DynArrDrv.c < prev    next >
C/C++ Source or Header  |  1992-08-18  |  2KB  |  74 lines

  1. #include "SYSTEM_.h"
  2.  
  3. #ifndef DEFINITION_DynArray
  4. #include "DynArray.h"
  5. #endif
  6.  
  7. #ifndef DEFINITION_IO
  8. #include "IO.h"
  9. #endif
  10.  
  11. static LONGINT i;
  12. static CARDINAL j;
  13. typedef struct S_1 {
  14.     LONGINT A[100000 - 1 + 1];
  15. } t;
  16. static t *p;
  17. static LONGINT s;
  18.  
  19.  
  20. void BEGIN_MODULE()
  21. {
  22.   BEGIN_DynArray();
  23.   BEGIN_IO();
  24.  
  25.   s = 10;
  26.   DynArray_MakeArray((ADDRESS *)&p, &s, (LONGINT)sizeof(LONGINT));
  27.   {
  28.     LONGINT B_1 = 1, B_2 = s;
  29.  
  30.     if (B_1 <= B_2)
  31.       for (i = B_1;; i += 1) {
  32.         p->A[i - 1] = i;
  33.         if (i >= B_2) break;
  34.       }
  35.   }
  36.   for (j = 1; j <= 13; j += 1) {
  37.     DynArray_ExtendArray((ADDRESS *)&p, &s, (LONGINT)sizeof(LONGINT));
  38.     if (p == NIL) {
  39.       IO_WriteS((System_tFile)IO_StdOutput, (STRING)"Extend Error", 12L);
  40.       IO_WriteNl((System_tFile)IO_StdOutput);
  41.     }
  42.     {
  43.       LONGINT B_3 = s / 2 + 1, B_4 = s;
  44.  
  45.       if (B_3 <= B_4)
  46.         for (i = B_3;; i += 1) {
  47.           p->A[i - 1] = i;
  48.           if (i >= B_4) break;
  49.         }
  50.     }
  51.     {
  52.       LONGINT B_5 = 1, B_6 = s;
  53.  
  54.       if (B_5 <= B_6)
  55.         for (i = B_5;; i += 1) {
  56.           if (p->A[i - 1] != i) {
  57.             IO_WriteS((System_tFile)IO_StdOutput, (STRING)"Error j, i, p^[i] =", 19L);
  58.             IO_WriteI((System_tFile)IO_StdOutput, (LONGINT)j, 5L);
  59.             IO_WriteLong((System_tFile)IO_StdOutput, i, 5L);
  60.             IO_WriteLong((System_tFile)IO_StdOutput, p->A[i - 1], 10L);
  61.             IO_WriteNl((System_tFile)IO_StdOutput);
  62.           }
  63.           if (i >= B_6) break;
  64.         }
  65.     }
  66.     IO_WriteS((System_tFile)IO_StdOutput, (STRING)"j, size = ", 10L);
  67.     IO_WriteI((System_tFile)IO_StdOutput, (LONGINT)j, 5L);
  68.     IO_WriteLong((System_tFile)IO_StdOutput, s, 10L);
  69.     IO_WriteS((System_tFile)IO_StdOutput, (STRING)" ok", 3L);
  70.     IO_WriteNl((System_tFile)IO_StdOutput);
  71.   }
  72.   IO_CloseIO();
  73. }
  74.